import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../pages/Login'
import Home from '../pages/Home'

import welcome from '@/pages/Home/home.vue'
import adminGroup from '@/pages/adminGroup'
import adminList from '@/pages/adminList'
import userList from '@/pages/userList'
import userGroup from '@/pages/userGroup'
import userWallet from '@/pages/userWallet'
import userState from '@/pages/userState'
import userFundFlow from '@/pages/userFundFlow'
import userCard from '@/pages/userCard'
import userRealName from '@/pages/userRealName'
import userIntegral from '@/pages/userIntegral'
import userRedeem from '@/pages/userRedeem'
import userUShield from '@/pages/userUShield'
import stock from '@/pages/stock'
import OTCwhitelist from '@/pages/OTCwhitelist'
import OTCorders from '@/pages/OTCorders'
import OTClist from '@/pages/OTClist'
import rechargeAddress from '@/pages/rechargeAddress'
import rechargeOrders from '@/pages/rechargeOrders'
import IPOcalendar from '@/pages/IPOcalendar'
import IPOorders from '@/pages/IPOorders'
import IPOpurchase from '@/pages/IPOpurchase'
import IPOwhitelist from '@/pages/IPOwhitelist'
import withdraw from '@/pages/withdraw'
import integralLevel from '@/pages/integralLevel'
import integralExchange from '@/pages/integralExchange'
import menuList from '@/pages/menuList'
import news from '@/pages/news'
import FinancialOrders from '@/pages/FinancialOrders'
import FinancialManage from '@/pages/FinancialManage'
import systemConfiguration from '@/pages/systemConfiguration'
import systemCollection from '@/pages/systemCollection'
import module from '@/pages/module'
import positions from '@/pages/positions'
import stencil from '@/pages/stencil'
import message from '@/pages/message'




Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'hash',
  routes: [
    { path: '/', redirect: '/Login' },
    { path: '/Login', name: 'Login', component: Login },
    {
      path: '/Home', name: 'Home', component: Home, children: [
        { path: '/welcome', name: 'welcome', component: welcome },
        { path: '/adminGroup', name: 'adminGroup', component: adminGroup },
        { path: '/adminList', name: 'adminList', component: adminList },
        { path: '/userList', name: 'userList', component: userList },
        { path: '/userGroup', name: 'userGroup', component: userGroup },
        { path: '/userWallet', name: 'userWallet', component: userWallet },
        { path: '/userState', name: 'userState', component: userState },
        { path: '/userFundFlow', name: 'userFundFlow', component: userFundFlow },
        { path: '/userCard', name: 'userCard', component: userCard },
        { path: '/userRealName', name: 'userRealName', component: userRealName },
        { path: '/userIntegral', name: 'userIntegral', component: userIntegral },
        { path: '/userRedeem', name: 'userRedeem', component: userRedeem },
        { path: '/userUShield', name: 'userUShield', component: userUShield },
        { path: '/stock', name: 'stock', component: stock },
        { path: '/OTCwhitelist', name: 'OTCwhitelist', component: OTCwhitelist },
        { path: '/OTCorders', name: 'OTCorders', component: OTCorders },
        { path: '/OTClist', name: 'OTClist', component: OTClist },
        { path: '/rechargeAddress', name: 'rechargeAddress', component: rechargeAddress },
        { path: '/rechargeOrders', name: 'rechargeOrders', component: rechargeOrders },
        { path: '/IPOcalendar', name: 'IPOcalendar', component: IPOcalendar },
        { path: '/IPOorders', name: 'IPOorders', component: IPOorders },
        { path: '/IPOpurchase', name: 'IPOpurchase', component: IPOpurchase },
        { path: '/IPOwhitelist', name: 'IPOwhitelist', component: IPOwhitelist },
        { path: '/withdraw', name: 'withdraw', component: withdraw },
        { path: '/integralLevel', name: 'integralLevel', component: integralLevel },
        { path: '/integralExchange', name: 'integralExchange', component: integralExchange },
        { path: '/menuList', name: 'menuList', component: menuList },
        { path: '/news', name: 'news', component: news },
        { path: '/FinancialOrders', name: 'FinancialOrders', component: FinancialOrders },
        { path: '/FinancialManage', name: 'FinancialManage', component: FinancialManage },
        { path: '/systemConfiguration', name: 'systemConfiguration', component: systemConfiguration },
        { path: '/systemCollection', name: 'systemCollection', component: systemCollection },
        { path: '/module', name: 'module', component: module },
        { path: '/positions', name: 'positions', component: positions },
        { path: '/stencil', name: 'stencil', component: stencil },
        { path: '/message', name: 'message', component: message },
        
      ]

    }

  ]
});
router.beforeEach((to, from, next) => {
  if (to.path == '/Login') {
    next()
  } else {
    let token = localStorage.getItem('token');
    if (token === 'null' || !token) {
      next('/Login')
    } else {
      next();
    }
  }
});
export default router;
